import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86185
 * Date: 2023-10-24
 * Time: 22:44
 */
public class Exam1024 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.next();
        String str2 = scanner.next();
        int p1 = 0;
        int p2 = 0;
        int max = 0;
        int flag = 0;
        int count = 0;
        while (p2 < str2.length()) {
            char c1 ;
            char c2 = str2.charAt(p2);
            if(str1.indexOf(c2) != -1) {
                p1 = str1.indexOf(c2);
                c1 = str1.charAt(p1);
                while (p2 < str2.length() && p1 < str1.length() && c1 == c2) {
                    c1 = str1.charAt(p1);
                    c2 = str2.charAt(p2);
                    count++;
                    p1++;
                    p2++;
                }
                if(count > max) {
                    max = count;
                }
                flag++;

            } else {
                p2++;
                continue;
            }
            p2 = flag;
            count = 0;
        }
        System.out.println(max);
    }
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String string = scanner.next();
        for (int i = string.length() - 1; i >= 0; i--) {
            System.out.print(string.charAt(i));
        }
    }
}
